<template>
	<view class="">
		<block v-if="index==0">
			<view class="d-flex-yCenter bgColor-white" v-for="(item,index)  in mygroupList" :key="index"
				style="padding: 16rpx 0rpx 16rpx 36rpx;border-top: 1px  solid #DFDFDF; ">
				<view class="bg_00 border-rs-y" style="width: 35px;height: 35px; margin-right: 24rpx;">
					<image :src="item.headimg" mode="widthFix" style="width: 100%;height: 100%;"></image>
				</view>
				<view class="">
					{{item.nickname}}
				</view>
			</view>
		</block>
		<block v-if="index==1">
			<view class="d-flex-yCenter bgColor-white" v-for="(item,index)  in mygroupList" :key="index"
				style="padding: 16rpx 0rpx 16rpx 36rpx;border-top: 1px  solid #DFDFDF; ">
				<view class="bg_00 border-rs-y" style="width: 35px;height: 35px; margin-right: 24rpx;">
					<image :src="item.headimg" mode="widthFix" style="width: 100%;height: 100%;"></image>
				</view>
				<view class="">
					{{item.nickname}}
				</view>
			</view>
		</block>
		<view class="py-30 text-al-center">
			<u-loadmore icon :load-text='loadText' :status="status" @loadmore="addRandomData"></u-loadmore>
		</view>
	</view>
</template>
<script>
	import {
		http_mall_goods_lst,
		friendsList //我的团队列表
	} from '@/config/apiRouter.js'
	export default {
		props: {
			// index: {
			// 	type: Number, 
			// }
		},
		data() {
			return {
				status: 'loadmore', //status对应的值loadText的key就是显示内容
				limit: 10, //条数
				page: 1, //页数
				index: 0,
				last_page: null, //末尾页数
				type: null, //参数jiji 
				loadText: {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '哦豁！着 没有更多数据了'
				},
				// 团队列表
				mygroupList: [],
			}
		},
		onShow() {

		},
		// watch: {
		// 	last_page(value) {
		// 		console.log(this.last_page);
		// 		if (this.page == this.last_page || value == 0) this.status = 'nomore'
		// 	},

		// },
		methods: {
			friendsLists(index) {
				console.log(index, 'active')
				this.type = index + 1;
				this.index = index;
				console.log(this.type, '直接间接')
				this.mygroupList = []; //清空数据
				this.friendsListsAll();
			},
			friendsListsAll() {
				friendsList({
					type: this.type,
					limit: this.limit, //每页的数量
					page: this.page //当前页
				}).then(res => {
					console.log(res, '数据')
					if (res.data.total !== 0) {
						console.log(res, '成功')
						this.last_page = res.data.last_page;
						this.mygroupList.push(...res.data.data);
						console.log(this.mygroupList, 'mygroupList');
					} else {
						console.log(res, '失败')
						this.status = 'nomore'
					}
				})
			},
			// 加载更多，无需参数 onReachBottom 
			addRandomData() {
				console.log('当前页:', this.page, '末页:', this.last_page);
				if (this.page == this.last_page || this.last_page == 0) {
					this.status = 'nomore'
					return;
				}
				this.page++
				this.friendsListsAll()
			},
		}
	}
</script>

<style>
</style>
